package top.zsyle.sycc.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import top.zsyle.sycc.service.ICreateTokenService;

import java.util.UUID;
import java.util.concurrent.TimeUnit;
@Service
public class CreateTokenServiceImpl implements ICreateTokenService {

    @Autowired
    private RedisTemplate<Object,Object> redisTemplate;

    @Override
    public String createToken(String courseIds) {
        Long loginId = 7L;
        String key = loginId+":"+courseIds;
        String value = UUID.randomUUID().toString();
        //设置过期时间，一个项目统一使用一种时间格式（毫秒）15*60*1000
        redisTemplate.opsForValue().set(key,value,900000, TimeUnit.MILLISECONDS);
        return value;
    }
}
